package com.facishare.open.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;

import java.util.Arrays;

/**
 * Created by linchf on 2016/7/25.
 */

@Slf4j
public class LogAspect {

    public Object around(ProceedingJoinPoint point) throws Throwable {
        String className = point.getTarget().getClass().getSimpleName();
        String methodName = point.getSignature().getName();

        long startTime = System.currentTimeMillis();
        try {
            return point.proceed();
        }finally {
            log.info("timeCost [methodName:{}]. params: {}. time: {}", className + "." + methodName,
                    Arrays.toString(point.getArgs()), (System.currentTimeMillis() - startTime));
        }

    }
}
